package cn.itcast.account.web;

import cn.itcast.account.service.AccountService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 虎哥
 */
@RestController

@RequestMapping("account")
public class AccountController {

    @Autowired
    private AccountService accountService;

    @PutMapping("/{userId}/{money}")
    @ApiOperation(value="金额扣减")
    public ResponseEntity<Boolean> deduct(@PathVariable("userId") String userId, @PathVariable("money") Integer money) {
        if(accountService.deduct(userId,money)){
            return ResponseEntity.ok(true);
        }
        return ResponseEntity.ok(false);
        // 示例：
    }
}
